import './App.scss'
import { Router, Redirect, Route, Switch } from 'react-router-dom'
// import Layout from '@/pages/Layout'
// import Login from './pages/Login'
// import NotFound from '@/pages/404'
import AuthRoute from './components/auth'
import customHistory from './utils/history'
import { Spin } from 'antd'
// 测试页面
import Test from './pages/test'
// 路由懒加载
import { lazy, Suspense } from 'react'
const Layout = lazy(() => import('@/pages/Layout'))
const Login = lazy(() => import('./pages/Login'))
const NotFound = lazy(() => import('@/pages/404'))
function App() {
  return (
    <Router history={customHistory}>
      <Suspense
        fallback={
          <div className="loading">
            <Spin>页面努力加载中</Spin>
          </div>
        }>
        <div className="app">
          <Switch>
            <Redirect exact from="/" to="/home"></Redirect>
            {/* <Route path="/home" component={Layout}></Route> */}
            {/* {AuthRoute()} */}
            <AuthRoute path="/home" component={Layout}></AuthRoute>
            {/* <Route path="/home" component={Layout}></Route> */}
            {/* <Route
            path="/home"
            render={(props) => {
              console.log(props)
              if (isAuth()) {
                return <Layout></Layout>
              }
              // return <Login></Login>
              else {
                console.log(history)
                props.history.replace('/login')
              }
            }}></Route> */}
            <Route path="/login" component={Login}></Route>
            <Route path="/test" component={Test}></Route>
            <Route component={NotFound}></Route>
          </Switch>
        </div>
      </Suspense>
    </Router>
  )
}

export default App
